import { fileURLToPath, URL } from 'node:url'
import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
import vueDevTools from 'vite-plugin-vue-devtools'
import { join, dirname } from 'node:path'

export default defineConfig({
    plugins: [vue(), vueDevTools()],
    resolve: {
        alias: {
            '@public': fileURLToPath(new URL('./public', import.meta.url)),
            '@': fileURLToPath(new URL('./src', import.meta.url))
        }
    },
    build: {
        outDir: 'dist/lib',
        cssCodeSplit: true,
        emptyOutDir: true,
        lib: {
            entry: './src/index.js',
            name: 'commonComponents',
            fileName: 'index',
            formats: ['es', 'umd']
        },
        rollupOptions: {
            external: [
                // 'axios',
                // 'echarts',
                // 'js-cookie',
                // 'lodash',
                // 'moment',
                // 'naive-ui',
                // 'perfume.js',
                'vue'
            ]
        }
    }
})
